//
// Created by Tan Ke on 2023/11/25.
//

#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int missingNumber(int* nums, int numsSize)
{
    long long sum = 0;

    if (numsSize % 2 == 0) {
        sum = numsSize / 2;
        sum *= (numsSize + 1);
    } else {
        sum = (numsSize + 1) / 2;
        sum *= numsSize;
    }

    for (int i = 0; i < numsSize; i ++) {
        sum -= nums[i];
    }

    return (int)sum;
}


int main(void)
{
    int nums[9] = {9, 6, 4, 2, 3, 5, 7, 0, 1};
    printf("%d\n", missingNumber(nums, 9));
    return 0;
}